using System.ComponentModel;
using System.Workflow.ComponentModel;
using TechHeadBrothers.Portal.Web.SilverlightStreaming;

namespace TechHeadBrothers.Workflows.Activities
{
    public partial class UploadToSilverlightStreaming : Activity
    {
        public static DependencyProperty AccountIDProperty =
            DependencyProperty.Register("AccountID", typeof (string), typeof (UploadToSilverlightStreaming));

        public static DependencyProperty AccountKeyProperty =
            DependencyProperty.Register("AccountKey", typeof (string), typeof (UploadToSilverlightStreaming));

        public static DependencyProperty FilesetNameProperty =
            DependencyProperty.Register("FilesetName", typeof (string), typeof (UploadToSilverlightStreaming));

        public static DependencyProperty ZipPathProperty =
            DependencyProperty.Register("ZipPath", typeof (string), typeof (UploadToSilverlightStreaming));

        /// <summary>
        /// Initializes a new instance of the <see cref="UploadToSilverlightStreaming"/> class.
        /// </summary>
        public UploadToSilverlightStreaming()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Gets or sets the account ID.
        /// </summary>
        /// <value>The account ID.</value>
        [Description("AccountID of the silverlight service")]
        [Category("Silverlight")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string AccountID
        {
            get { return ((string) (GetValue(AccountIDProperty))); }
            set { SetValue(AccountIDProperty, value); }
        }

        /// <summary>
        /// Gets or sets the account key.
        /// </summary>
        /// <value>The account key.</value>
        [Description("AccountKey of the Silverlight service")]
        [Category("Silverlight")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string AccountKey
        {
            get { return ((string) (GetValue(AccountKeyProperty))); }
            set { SetValue(AccountKeyProperty, value); }
        }

        /// <summary>
        /// Gets or sets the zip path.
        /// </summary>
        /// <value>The zip path.</value>
        [Description("Zip path of the file to upload")]
        [Category("Silverlight")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string ZipPath
        {
            get { return ((string) (GetValue(ZipPathProperty))); }
            set { SetValue(ZipPathProperty, value); }
        }

        /// <summary>
        /// Gets or sets the name of the fileset.
        /// </summary>
        /// <value>The name of the fileset.</value>
        [Description("Name of the fileset")]
        [Category("Silverlight")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string FilesetName
        {
            get { return ((string) (GetValue(FilesetNameProperty))); }
            set { SetValue(FilesetNameProperty, value); }
        }


        /// <summary>
        /// Called by the workflow runtime to execute an activity.
        /// </summary>
        /// <param name="executionContext">The <see cref="T:System.Workflow.ComponentModel.ActivityExecutionContext"></see> to associate with this <see cref="T:System.Workflow.ComponentModel.Activity"></see> and execution.</param>
        /// <returns>
        /// The <see cref="T:System.Workflow.ComponentModel.ActivityExecutionStatus"></see> of the run task, which determines whether the activity remains in the executing state, or transitions to the closed state.
        /// </returns>
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            SilverlightStreamingManager manager = new SilverlightStreamingManager(AccountID, AccountKey);
            manager.AddFileSet(ZipPath, FilesetName);
            return base.Execute(executionContext);
        }
    }
}